package com.etc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author 武晓春
 * @Description 生成文档
 * @Date 2021/2/20  11:43
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.etc.controller")).paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo(){
        return  new ApiInfoBuilder()
//                页面标题
                .title("优品购")
//                        创建人信息
                .contact(new Contact("MrWu","http://www.cnblogs.com/zs-notes/category/1258467.html","1594170406@qq.com"))
                .version("1.0")
                .description("Api 描述")
                .build();


    }


}
